package com.theyeasy.dvmini.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

import com.theyeasy.dvmini.socket.PcWebSocketHandler;
import com.theyeasy.dvmini.util.RedisUtil;

@Configuration
@EnableWebMvc
@EnableWebSocket
public class WebSocketConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer {

	public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
		// 万小二的socket地址
		registry.addHandler(pcWebSocketHandler(), "/web/socket/**/0").setAllowedOrigins("*");
		// 销售代表客服地址
		registry.addHandler(pcWebSocketHandler(), "/web/socket/**/1").setAllowedOrigins("*");
	}

	@Bean
	public WebSocketHandler pcWebSocketHandler() {
		return new PcWebSocketHandler();
	}

}
